(function  ( window ) {

Itcast.fn.extend({
    css:function(key,value){
        if(Itcast.isArrayLike(key)){
            var obj={},
                target=this[0];
            Itcast.each(key,function(i,v){
                obj[v]=target.style(v)||window.getComputedStyle(target)[v];
            });
            return obj;
        }else if(Object.prototype.toString.call(key)==="[object Object]"){
            return this.each(function(){
                for(var k in key){
                    this.style[k]=key[k];
                }
            });
        }else if(typeof  key==="string"){
            if(value===undefined){
                return this[0].style[key]||window.getComputedStyle(this[0])[key];
            }else if(typeof value==="string"){
                return this.each(function(){
                    this.style[key]=value;
                });
            }else if(typeof value==="function"){
                return this.each(function(i){
                    this.style[key]=value(i,this.style[key]||window.getComputedStyle(this)[key])
                });
            }
        }
    },
    addClass:function(className){
        return this.each(function(){
            if(this.className){
                this.className+=" "+className;
            }else{
                this.className=className
            }
        })
    },
    hasClass:function(className){
        className=className.trim();
        for(var i=0;i<this.length;i++){
            var dom=this[i],
                classNames=dom.className&&dom.className.split(" ");
            if(classNames&&classNames.indexOf(className)>-1){
                return true;
            }
        }
        return false;
    },
    removeClass:function(className){
        className=className.trim();
        return this.each(function(){
            var classNames=this.className&&this.className.split(" ");
            if(!classNames)return;
            var index;
            while((index=classNames.indexOf(className))!=-1){
                classNames.splice(index,1);
            }
            this.className=classNames.join("");
        })
    },
    toggleClass:function(className){
        return this.each(function(){
            if(I(this).hasClass(className)){
                I(this).removeClass(className);
            }else{
                I(this).addClass(className);
            }
        });
    }





})



})( window )